#pragma once

#include "IXGifDraw.h"
#include "Logic/Include/XBaseObjImpl.h"


class CXGifDrawImpl : public CXBaseObjImpl<IXGifDraw>
{
    typedef CXBaseObjImpl<IXGifDraw> superclass;

    BEGIN_DEF_SKIN_CLASS(CXGifDrawImpl, superclass, gs_strGuidXSkin)
        IMP_BASIC_INTF(IXGifDraw, 0)
        IMP_BASIC_INTF(IXDraw, eIntf_NoCreate)
    END_DEF_SKIN_CLASS();
public:
    CXGifDrawImpl();
    virtual ~CXGifDrawImpl();

public:
    // IXGifDraw
    virtual HRESULT STDMETHODCALLTYPE   put_GifPath(IN LPCTSTR szXNC);
    virtual HRESULT STDMETHODCALLTYPE   get_ImagePath(OUT BSTR* pbstrXNC);

    virtual DWORD   STDMETHODCALLTYPE   GetDelayValue();
    virtual DWORD   STDMETHODCALLTYPE   GetFrameCount();
    virtual void    STDMETHODCALLTYPE   get_GifSize(OUT SIZE* pGifSize);
    virtual void    STDMETHODCALLTYPE   NextFrame();

    // IXDraw
    virtual HRESULT STDMETHODCALLTYPE   Draw(IN XCANVAS xCanvas, const RECT* lpDes);
    virtual HRESULT STDMETHODCALLTYPE   Draw(IN XCANVAS xCanvas, IN const RECT* lpSrc, IN const RECT* lpDes);
    virtual BOOL    STDMETHODCALLTYPE   IsDrawValid();

    virtual void    STDMETHODCALLTYPE   EnableColorize(IN BOOL bEnable);
    virtual void    STDMETHODCALLTYPE   Colorize(IN int hue, IN int sat, IN int light);

    // IBaseObj
    virtual void    STDMETHODCALLTYPE   OnFinalRelease();

protected:
    // CXGifDrawImpl
    void            ReleaseData();

protected:
    // CXGifDrawImpl
    XString         m_strXNC;
    XGIF            m_xGif;

    SIZE            m_sizeGif;

    typedef std::vector<XIMAGE> GifFrame;
    GifFrame        m_GifFrame;

    typedef std::vector<DWORD> DelayValues;
    DelayValues     m_DelayValues;

    size_t          m_nCurFrameIndex;
};


